package decorator_pattern;

/**
 *
 * ConcreteDecorator 通过 继承 Decorator 得到 component  然后具体实现 component 的行为
 * 构造函数是接受component参数关键
 * @author lynn
 * @date 18-12-8 上午7:10
 */
public class ConcreteDecoratorA extends Decorator{

    private char borderChar;

    public ConcreteDecoratorA(Component component, char borderChar) {
        super(component);
        this.borderChar = borderChar;
    }

    /**
     * get all columns
     *
     * @return
     */
    @Override
    public int getColumns() {
        return 1 + this.component.getColumns() + 1;
    }

    /**
     * get all rows
     *
     * @return
     */
    @Override
    public int getRows() {
        return this.component.getRows();
    }

    /**
     * get text for given row number
     *
     * @param row
     * @return
     */
    @Override
    public String getRowText(int row) {
        return borderChar + this.component.getRowText(row) + borderChar;
    }
}
